package com.hw.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.HashMap;

@WebServlet( "/jojo")
public class EServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json; charset=utf-8");
        HashMap<String,Integer> hashMap=new HashMap<>();

        hashMap.put("小红",01);
        hashMap.put("小明",02);
        hashMap.put("小王",01);
        hashMap.put("小李",02);


        PrintWriter out=response.getWriter();
        out.write(hashMap.toString());


    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Enumeration<String> data= req.getParameterNames();
        while (data.hasMoreElements()){
            System.out.println(data.nextElement());
        }
    }
}
